﻿@{
    ViewBag.Title = "OrderDetailStatisticsList";
    Layout = "~/Areas/Shared/_spList.cshtml";
}
@model Kaiser.Modules.DC.Models.OrderInput
<div region="center" border="false" style="width: 500px; height: 300px; margin: 1px;
    padding: 0px; overflow-y: hidden">
    <div id="grid">
    </div>
</div>

<div id="Dlg-Edit" title="编辑" style="width: 500px; height: 250px;  "  >
    <div style="padding: 20px 20px 40px 40px;">
        <form method="post" id="Form1">
        <table>
         
            <tr>
                <td class="itemtxt">
                    序号：
                </td>
                <td style="text-align: right">
                    奶茶名称：
                </td>
                <td style="text-align: right">
                    数量：
                </td>
                
            </tr>
            <tr>
                <td style="text-align: right">
                    描述：
                </td>
                <td>
                   @Html.TextBoxFor(m => Model.OrderDesc, new { @Class = "easyui-validatebox", @required = "true",@validType="string", @style = "width: 200px;" })
                </td>
            </tr>
        </table>
        </form>
    </div>
</div>
<script type="text/javascript">
    // 全局变量
    var grid;
    var dlg_Edit;
    var dlg_Edit_form;
    var searchWin;
    var searchForm;
    var virpath = ""; //网站的虚拟目录 如：/ShopManager
    var config = {
        ListActionURL: '@Url.Action("OrderList", "DCManage", new { area = "DC" })',
        ListDetialURL: '@Url.Action("OrderDetails", "DCManage", new { area = "DC" })'
    };


    $(function () {


        grid = $('#grid').datagrid({
            title: '点餐发布管理',
            iconCls: 'icon-save',
            methord: 'post',
            url: config.ListActionURL,
            method: 'post',
            sortName: 'OrderCode',
            sortOrder: 'desc',
            idField: 'OrderCode',
            pageSize: 10,
            striped: true,
            columns: [[
					{ field: 'OrderName', title: '描述', width: 150, sortable: true, formatter: function (value, row, index) {
					    var html = "<a class='view' href='javascript:void(0)'>" + value + "</a>"
					    return html;
					}
					},
                    { field: 'OrderCreateUserFullName', title: '发布人', width: 150, sortable: true },
                    { field: 'OrderTime', title: '发布日期', width: 150, sortable: true }
				]],
            fit: true,
            pagination: true,
            rownumbers: true,
            fitColumns: true,
            singleSelect: false,
            onHeaderContextMenu: function (e, field) {
                e.preventDefault();
                if (!$('#tmenu').length) {
                    createColumnMenu();
                }
                $('#tmenu').menu('show', {
                    left: e.pageX,
                    top: e.pageY
                });
            },
            onLoadSuccess: function (data) {
                $(".view").click(function () {
                    dlg_Edit_form.form('clear');
                    dlg_Edit.dialog('open');
                    dlg_Edit.dialog('setTitle', '订餐明细');

                    dlg_Edit_form.url = virpath + config.ListDetialURL;
                })
            }


        });




        $('#btn-search,#btn-search-cancel').linkbutton();
        searchWin = $('#search-window').window({
            iconCls: 'icon-search',
            closed: true,
            modal: true
        });
        searchForm = searchWin.find('form');

        $('body').layout();
    });




    function createColumnMenu() {
        var tmenu = $('<div id="tmenu" style="width:100px;"></div>').appendTo('body');
        var fields = grid.datagrid('getColumnFields');
        for (var i = 0; i < fields.length; i++) {
            $('<div iconCls="icon-ok"/>').html(fields[i]).appendTo(tmenu);
        }
        tmenu.menu({
            onClick: function (item) {
                if (item.iconCls == 'icon-ok') {
                    grid.datagrid('hideColumn', item.text);
                    tmenu.menu('setIcon', {
                        target: item.target,
                        iconCls: 'icon-empty'
                    });
                } else {
                    grid.datagrid('showColumn', item.text);
                    tmenu.menu('setIcon', {
                        target: item.target,
                        iconCls: 'icon-ok'
                    });
                }
            }
        });
    }

    function getSelectedArr() {
        var ids = [];

        var rows = $('#grid').datagrid('getSelections');
        for (var i = 0; i < rows.length; i++) {
            ids.push(rows[i].OrderCode);
        }

        return ids;
    }
    function getSelectedID() {
        var ids = getSelectedArr();
        return ids.join(',');
    }
    function arr2str(arr) {
        return arr.join(',');
    }

    dlg_Edit = $('#Dlg-Edit').dialog({
        closed: true,
        modal: true,
        toolbar: [{
            text: '关闭',
            iconCls: 'icon-no',
            handler: function () {
                dlg_Edit.dialog('close');
            }
        }]

    });

    dlg_Edit_form = dlg_Edit.find('form');
    
  

    function OpensearchWin() {
        searchWin.window('open');
        searchForm.form('clear');
    }


    function closeSearchWindow() {
        searchWin.window('close');
    }
</script>
